package com.xinchao.ck_mips.http;

import android.content.Context;

import com.xinchao.ck_mips.BuildConfig;
import com.xinchao.ck_mips.InterceptorUtil;
import com.xinchao.machine.digital_advertise.IBaseMachine;
import com.xinchao.rxtools.rxhttp.RxHttpFactory;
import com.xinchao.rxtools.rxhttp.SingleRxHttp;

/**
 * Created by wq on 2019/5/23.
 */
public class CKRxHttp {

    public static SingleRxHttp initRxHttp(IBaseMachine iBaseMachine, String url, Context mContext) {
        SingleRxHttp singleRxHttp = RxHttpFactory.create(url).setTimeOut(60).setDebug(true);
        singleRxHttp
                .putHeaders("appversion", "" + BuildConfig.VERSION_NAME)
                .putHeaders("appversioncode", "" + BuildConfig.VERSION_CODE)
                //设备类型、编号
                .putHeaders("devicemodel", iBaseMachine.getModel())
                //固件版号
                .putHeaders("firmwareversion", iBaseMachine.getFrameworkVersion())
                .putHeaders("uniqueDeviceCode", iBaseMachine.getUniqueDeviceCode())
                //.putHeaders("deviceNum", DeviceInfoUtil.getInstance(mContext).getDeviceId())
                .addInterceptor(InterceptorUtil.AddHeaderParameterInterceptor(iBaseMachine, mContext))
                .addInterceptor(InterceptorUtil.LogInterceptor()); //添加日志拦截器; //头部拦截器

        return singleRxHttp;
    }

}
